package com.zhaohanlin.start;

import org.junit.Test;

/**
 * @author zhaohanlin
 */

public class InterfaceClassTest1{
static class UserDog{
    String name;
    Integer age;
    public Integer getAge(){return age;}
    public void setAge(Integer age){this.age=age;}
    public String getName(){return name;}
    public void setName(String name){this.name=name;}

}
interface UserService{
    /**
    按主键添加一名用户
     @param userDog 前端传递过来的信息。
     */
    void insert(UserDog userDog);
    /**
     * 删除一名用户
     * @param id 编号
     */
    void deleteById(int id);
    /**
     * 按主键修改一名用户
     * @param UserDog 前端传递过来的信息
     */
    void updateById(UserDog UserDog);
    /**
     * 按主键查询一名用户
     * @param id 编号
     */
     UserDog selectById(int id);

}
static class UserServiceImpl implements UserService{
    @Override
    public void insert(UserDog userDog) {

    }

    @Override
    public void deleteById(int id) {

    }

    @Override
    public void updateById(UserDog UserDog) {

    }


    @Override
    public UserDog selectById(int id) {
        System.out.println("查询成功");
        //模拟
        UserDog user =new UserDog();
        user.setAge(18);
        user.setName("赵凯");

        return user;
    }
}
    @Test
    public void userService(){
//使用多态写法
        UserService userService=new UserServiceImpl();
        userService.insert(new UserDog());
        userService.selectById(1);
        userService.deleteById(1);
        userService.updateById(new UserDog());

    }
    }


